package com.wuxiaofan.api;

import com.wuxiaofan.api.request.ScheduleRequest;
import com.wuxiaofan.entity.model.ScheduleMongo;
import com.wuxiaofan.service.ScheduleService;
import com.wuxiaofan.vo.ReturnResult;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.annotation.Resource;
import net.bytebuddy.asm.Advice.Return;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wuxiaofan
 * @date 2021/11/2 9:17 上午
 */
@RestController
@RequestMapping("schedule")
public class ScheduleApi {
    @Resource
    private ScheduleService scheduleService;

    @ApiOperation(value = "上传排班")
    @PostMapping("saveSchedule")
    public ReturnResult saveSchedule(@RequestBody ScheduleMongo scheduleMongo) {
        scheduleService.save(scheduleMongo);
        return ReturnResult.success("排班上传成功");
    }


    @ApiOperation(value = "获取排班分页列表")
    @PostMapping("schedule/list")
    public ReturnResult schedule(ScheduleRequest scheduleRequest) {
        List<ScheduleMongo> scheduleMongoList = scheduleService.all(scheduleRequest);
        return ReturnResult.success("分页查询成功",scheduleMongoList);
    }

    @ApiOperation(value = "删除科室")
    @PostMapping("schedule/remove")
    public ReturnResult removeSchedule(String id){
        scheduleService.deleteById(id);
        return ReturnResult.success("删除成功");
    }
}
